<template>
    <div>
        <h2>等级显示</h2>
        <input type="button" value="新增" class="btn btn-primary" @click="add">
        <table class="table table-bordered">
            <tbody>
                <tr class="bg-primary">
                    <td>编号</td>
                    <td>等级名称</td>
                </tr>
                <tr v-for="item in quertinfo.data" :key="item.Id">
                    <td>{{item.Id}}</td>
                    <td>{{item.LevelName}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref,reactive,onMounted } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router=useRouter();

const quertinfo:any=reactive({
    data:[]
})



const add=()=>{
    router.push('/leveladd');
}
//周期函数
onMounted(()=>{
    getlevel();
})
const getlevel=()=>{
    //发送网络请求
    axios({
        method:'get',
        url:'/api/Member/GetLevel'
    })
    .then(res=>{
        console.log(res);
        quertinfo.data=res.data;
    })
    .catch(err=>{
        console.error(err);
    })
}



</script>

<style scoped>

</style>